package com.viphuli.http.handler;

import android.view.View;

import com.viphuli.common.Constants.TicketType;
import com.viphuli.fragment.PurchaseOrderPayResultFragment;
import com.viphuli.http.bean.page.PurchaseOrderInfoPage;
import com.viphuli.http.bean.part.PurchaseOrder;
import com.viphuli.http.bean.part.PurchasePayTicket;

public class PurchaseOrderPayResultHandler extends MyBaseHttpResponseHandler<PurchaseOrderPayResultFragment, PurchaseOrderInfoPage> {

	@Override
	public void deal() {
		PurchaseOrder order = page.getOrder();

		//填充数据
		caller.getNameText().setText(order.getName());
		caller.getTimeText().setText(order.createTimeMinute());
		caller.getSiteText().setText(order.address());
		caller.getTelText().setText(order.getTel());
		caller.getPayPriceText().setText(order.price());

		//优惠券
		PurchasePayTicket ticket = order.getTicket();
		if (ticket != null) {
			caller.getTicketLayout().setVisibility(View.VISIBLE);
			caller.getTicketText().setText(ticket.getName());

			if (TicketType.money.getType() == ticket.getTicketType()) {

				caller.getTicketTitleText().setText(TicketType.money.getName()+"：");

			} else if (TicketType.discount.getType() == ticket.getTicketType()) {

				caller.getTicketTitleText().setText(TicketType.discount.getName()+"：");

			} else {

				caller.getTicketTitleText().setText(TicketType.other.getName()+"：");

			}

		} else {
			caller.getTicketLayout().setVisibility(View.GONE);
		}

		//隐藏加载对话框
		caller.notEmpty();
	}

}
